package com.hd.appcommon.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hd.appcommon.entity.RoleDept;
import com.hd.appcommon.entity.vo.DeptSelectVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author administrator
 * @since 2020-11-24
 */
@Repository
@Mapper
public interface RoleDeptMapper extends BaseMapper<RoleDept> {

    @Select("select name as label, id as value from dept where id in " +
            " (select dept from role_dept where role_id = #{roleId} " +
            " and dept_type =  #{type} )")
    List<DeptSelectVo> getDeptsVoByRoleId(@Param("roleId") String roleId, @Param("type") Integer type);

}
